
$(function(){
    let form=layui.form
    form.verify({
        Pwd:[
           /^[\S]{6,15}$/,
           '密码必须是6-15位非空字符'
        ],
        newPwd:function(value){
           if(value===$('[name="oldPwd"]').val()){
               return '新密码不能与原密码一致'
           }
        },
        rePwd:function(value){
            if(value!==$('[name="newPwd"]').val()){
                return '两次密码不一致'
            }
        }
    })

    $('form').on('submit',function(e){
        e.preventDefault()
        axios({
            url:'/my/updatepwd',
            method:'post',
            data:$(this).serialize()
        }).then(({data:res})=>{
            if(res.status!==0){
                return layui.layer.msg(res.message)
            }

            layui.layer.msg(res.message)
            $('[type="reset"]').click()
            setTimeout(()=>{
              window.parent.location.href='/login.html'
            },1000)
        })
    })
})

 





